package com.wb.tcp.common.utils;

/**
 * @Author chenyong
 * @Description TODO
 * @Date 2022/12/11 11:55
 * @Version 1.0
 */
public class HexConvert {
    private HexConvert(){}

        public static String BinaryToHexString(byte[] bytes) {

            String hexStr = "0123456789ABCDEF";

            String result = "";

            String hex = "";

            for (byte b : bytes) {

                hex = String.valueOf(hexStr.charAt((b & 0xF0) >> 4));

                hex += String.valueOf(hexStr.charAt(b & 0x0F));

                result += hex;

            }

            return result.trim();

        }

        public static short bytes2Short2(byte[] b) {

            short i = (short) (((b[1] & 0xff) << 8) | b[0] & 0xff);

            return i;

        }
}
